USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[ProductsClassifications-Insert]    Script Date: [[20120914065000]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065000]]
-- Description:	Insert record into table [dbo].[ProductsClassifications]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[ProductsClassifications-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[ProductsClassifications-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[ProductsClassifications-Insert]
	/*@ProductClassification_RowNumber int =Null OUTPUT , 
	@ProductClassification_ID uniqueidentifier =Null  , 
	@ProductClassification_Code varchar(50) =Null  , 
	@ProductClassification_NameAr varchar(300) =Null  , 
	@ProductClassification_NameEn varchar(300) =Null  , 
	@ProductClassification_Notes varchar(max) =Null  , 
	@ProductClassification_Search varchar(max) =Null  , 
	@ProductClassification_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[ProductsClassifications](/*[ProductClassification_ID], [ProductClassification_Code], [ProductClassification_NameAr], [ProductClassification_NameEn], [ProductClassification_Notes], [ProductClassification_Search]*/)
	VALUES     (/*@ProductClassification_ID, @ProductClassification_Code, @ProductClassification_NameAr, @ProductClassification_NameEn, @ProductClassification_Notes, @ProductClassification_Search*/)

	/*SELECT @ProductClassification_RowNumber = [ProductClassification_RowNumber], @ProductClassification_TimeStamp = [ProductClassification_TimeStamp]
    FROM [dbo].[ProductsClassifications]
    WHERE  ( [ProductClassification_ID] =@ProductClassification_ID )
	AND  ( [ProductClassification_Code] =@ProductClassification_Code )
	AND  ( [ProductClassification_NameAr] =@ProductClassification_NameAr )
	AND  ( [ProductClassification_NameEn] =@ProductClassification_NameEn )
	AND  ( [ProductClassification_Notes] =@ProductClassification_Notes )
	AND  ( [ProductClassification_Search] =@ProductClassification_Search )*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[ProductsClassifications-update]    Script Date: [[20120914065000]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065000]]
-- Description:	Update record in table [dbo].[ProductsClassifications]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[ProductsClassifications-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[ProductsClassifications-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[ProductsClassifications-update]
	/*@ProductClassification_RowNumber int =Null OUTPUT , 
	@ProductClassification_ID uniqueidentifier =Null  , 
	@ProductClassification_Code varchar(50) =Null  , 
	@ProductClassification_NameAr varchar(300) =Null  , 
	@ProductClassification_NameEn varchar(300) =Null  , 
	@ProductClassification_Notes varchar(max) =Null  , 
	@ProductClassification_Search varchar(max) =Null  , 
	@ProductClassification_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [ProductClassification_TimeStamp]
    FROM [dbo].[ProductsClassifications]
    	WHERE ([ProductClassification_ID] = @ProductClassification_ID)

    IF  @OldTimeStamp = @ProductClassification_TimeStamp
    BEGIN*/
		Update [dbo].[ProductsClassifications] SET 
		/*[ProductClassification_ID] =@ProductClassification_ID, 
		[ProductClassification_Code] =@ProductClassification_Code, 
		[ProductClassification_NameAr] =@ProductClassification_NameAr, 
		[ProductClassification_NameEn] =@ProductClassification_NameEn, 
		[ProductClassification_Notes] =@ProductClassification_Notes, 
		[ProductClassification_Search] =@ProductClassification_Search*/
		/*WHERE ([ProductClassification_ID] = @ProductClassification_ID)*/
	/*END*/

	/*SELECT @ProductClassification_RowNumber = [ProductClassification_RowNumber], @ProductClassification_TimeStamp = [ProductClassification_TimeStamp]
    FROM [dbo].[ProductsClassifications]
	WHERE ([ProductClassification_ID] = @ProductClassification_ID)*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[ProductsClassifications-Insert-Update]    Script Date: [[20120914065000]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065000]]
-- Description:	Insert OR Update record into table [dbo].[ProductsClassifications]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[ProductsClassifications-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[ProductsClassifications-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[ProductsClassifications-Insert-Update]
	/*@ProductClassification_RowNumber int =Null OUTPUT , 
	@ProductClassification_ID uniqueidentifier =Null  , 
	@ProductClassification_Code varchar(50) =Null  , 
	@ProductClassification_NameAr varchar(300) =Null  , 
	@ProductClassification_NameEn varchar(300) =Null  , 
	@ProductClassification_Notes varchar(max) =Null  , 
	@ProductClassification_Search varchar(max) =Null  , 
	@ProductClassification_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[ProductsClassifications] 
					/*WHERE ([ProductClassification_ID] = @ProductClassification_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[ProductsClassifications](/*[ProductClassification_ID], [ProductClassification_Code], [ProductClassification_NameAr], [ProductClassification_NameEn], [ProductClassification_Notes], [ProductClassification_Search]*/)
		VALUES     (/*@ProductClassification_ID, @ProductClassification_Code, @ProductClassification_NameAr, @ProductClassification_NameEn, @ProductClassification_Notes, @ProductClassification_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [ProductClassification_TimeStamp]
		FROM [dbo].[ProductsClassifications]
    	WHERE ([ProductClassification_ID] = @ProductClassification_ID)

		IF  @OldTimeStamp = @ProductClassification_TimeStamp
		BEGIN*/
			Update [dbo].[ProductsClassifications] SET 
			/*[ProductClassification_ID] =@ProductClassification_ID, 
			[ProductClassification_Code] =@ProductClassification_Code, 
			[ProductClassification_NameAr] =@ProductClassification_NameAr, 
			[ProductClassification_NameEn] =@ProductClassification_NameEn, 
			[ProductClassification_Notes] =@ProductClassification_Notes, 
			[ProductClassification_Search] =@ProductClassification_Search*/
			/*WHERE ([ProductClassification_ID] = @ProductClassification_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @ProductClassification_RowNumber = [ProductClassification_RowNumber], @ProductClassification_TimeStamp = [ProductClassification_TimeStamp]
    FROM [dbo].[ProductsClassifications]
	WHERE ([ProductClassification_ID] = @ProductClassification_ID)*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[ProductsClassifications-Delete]    Script Date: [[20120914065000]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065000]]
-- Description:	delete records from table [dbo].[ProductsClassifications] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[ProductsClassifications-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[ProductsClassifications-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[ProductsClassifications-Delete]
	/*@ProductClassification_RowNumber int =null  , 
	@ProductClassification_ID uniqueidentifier =null  , 
	@ProductClassification_Code varchar(50) =null  , 
	@ProductClassification_NameAr varchar(300) =null  , 
	@ProductClassification_NameEn varchar(300) =null  , 
	@ProductClassification_Notes varchar(max) =null  , 
	@ProductClassification_Search varchar(max) =null  , 
	@ProductClassification_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[ProductsClassifications]
	WHERE /*( [ProductClassification_RowNumber] = ISNULL(@ProductClassification_RowNumber, [ProductClassification_RowNumber]) )
	AND ( [ProductClassification_ID] = ISNULL(@ProductClassification_ID, [ProductClassification_ID]) )
	AND ( [ProductClassification_Code] like ISNULL(@ProductClassification_Code, [ProductClassification_Code]) )
	AND ( [ProductClassification_NameAr] like ISNULL(@ProductClassification_NameAr, [ProductClassification_NameAr]) )
	AND ( [ProductClassification_NameEn] like ISNULL(@ProductClassification_NameEn, [ProductClassification_NameEn]) )
	AND ( [ProductClassification_Notes] like ISNULL(@ProductClassification_Notes, [ProductClassification_Notes]) )
	AND ( [ProductClassification_Search] like ISNULL(@ProductClassification_Search, [ProductClassification_Search]) )
	AND ( [ProductClassification_TimeStamp] = ISNULL(@ProductClassification_TimeStamp, [ProductClassification_TimeStamp]) )*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[ProductsClassifications-Select]    Script Date: [[20120914065000]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065000]]
-- Description:	select records from table [dbo].[ProductsClassifications] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[ProductsClassifications-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[ProductsClassifications-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[ProductsClassifications-Select]
	/*@ProductClassification_RowNumber int =null  , 
	@ProductClassification_ID uniqueidentifier =null  , 
	@ProductClassification_Code varchar(50) =null  , 
	@ProductClassification_NameAr varchar(300) =null  , 
	@ProductClassification_NameEn varchar(300) =null  , 
	@ProductClassification_Notes varchar(max) =null  , 
	@ProductClassification_Search varchar(max) =null  , 
	@ProductClassification_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[ProductsClassifications]
	WHERE /*( [ProductClassification_RowNumber] = ISNULL(@ProductClassification_RowNumber, [ProductClassification_RowNumber]) )
	AND ( [ProductClassification_ID] = ISNULL(@ProductClassification_ID, [ProductClassification_ID]) )
	AND ( [ProductClassification_Code] like ISNULL(@ProductClassification_Code, [ProductClassification_Code]) )
	AND ( [ProductClassification_NameAr] like ISNULL(@ProductClassification_NameAr, [ProductClassification_NameAr]) )
	AND ( [ProductClassification_NameEn] like ISNULL(@ProductClassification_NameEn, [ProductClassification_NameEn]) )
	AND ( [ProductClassification_Notes] like ISNULL(@ProductClassification_Notes, [ProductClassification_Notes]) )
	AND ( [ProductClassification_Search] like ISNULL(@ProductClassification_Search, [ProductClassification_Search]) )
	AND ( [ProductClassification_TimeStamp] = ISNULL(@ProductClassification_TimeStamp, [ProductClassification_TimeStamp]) )*/
END
GO
-- =============================================
